<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>插槽</title>
</head>
<body>
<div id="app">
    <alert-box>有bug发生</alert-box>
    <alert-box>有一个警告</alert-box>
    <alert-box></alert-box>
</div>

<!-- 开发环境版本，包含了有帮助的命令行警告 -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script type="text/javascript">
    /*
    组件插槽-父组件向子组件传递内容
     */
    Vue.component("alert-box", {
        template: `
            <div>
                <strong>ERROR:</strong>
                <slot>默认内容</slot>
            </div>
        `
    });
    var vue = new Vue({
        el: "#app",
        data: {},
    })
</script>
</body>
</html>
